package com.ocl.www.service;

import com.ocl.www.domain.Letter;
import com.ocl.www.mapper.LetterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2016/12/1.
 */
@Service
public class LetterService {

    @Autowired
    private LetterMapper letterMapper;

    /**
     *添加一条私信记录
     * @return 添加成功记录数 1
     * @throws Exception
     */
    public Integer insertLetter(Letter letter)throws Exception{

        return letterMapper.insertLetter(letter);

    }

    /**
     * 查询未读信息
     * @return
     * @throws Exception
     */
    public int selectNewLetter() throws Exception{

        return letterMapper.selectNewLetter();
    }

    /**
     * 查询给我的未读的私信
     * @param letter
     * @return
     * @throws Exception
     */
    public List<Letter> selectLettersWithReciverId(Letter letter)  throws Exception{
        return letterMapper.selectLettersWithReciverId(letter);
    }

    public Integer updateLetterOfIsread(Letter letter)   throws Exception{

        return letterMapper.updateLetterOfIsread(letter);
    }
}
